/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package homework04.by_gong;

/**
 *
 * @龚柳彬 2010404108
 */
public class IdCard {
    public static void main(String[] args) {
        String number = "45012345678912345X";
        boolean flag = true;
        if (number.length()!=18) {
            flag = false;
        }
        String numstr = "0123456789X";
        for (int i = 0; i < number.length(); i++) {
             char c = number.charAt(i);
            int temp = numstr.indexOf(c);
            if (temp<0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println("是合法的身份证号码");
        }     
        else{
            System.out.println("不是合法的身份证号码");
        }
    }
}
